package com.haixiaoke.saas.common.weChat.service;

import com.alibaba.fastjson2.JSONObject;
import com.haixiaoke.saas.common.core.domain.AjaxResult;
import com.haixiaoke.saas.common.weChat.domain.*;

/**
 * @author panda
 * @Date 2024/4/13
 **/
public interface WeChatService {

    /**
     * 微信下单
     *
     * @param unifiedOrder
     * @return
     */
    AjaxResult unifiedOrder(UnifiedOrder unifiedOrder);

    /**
     * 微信扫码支付
     *
     * @param unifiedOrder
     * @return
     */
    AjaxResult nativeOrder(UnifiedOrder unifiedOrder);

    /**
     * 微信退款
     *
     * @return
     */
    AjaxResult refundOrder(RefundOrder refundOrder);

    /**
     * 校验签名
     *
     * @param parseParam    回调请求参数
     * @param accountApiKey 微信支付分配的商户号密钥
     */
    boolean signCheck(ParseParam parseParam, String accountApiKey);

    RefundReqInfo getReqInfo(RefundParam refundParam);

    /**
     * 微信登录
     * @param code
     * @return
     * {
     * "openid":"用户唯一标识",
     * "session_key":"会话密钥",
     * "unionid":"用户在开放平台的唯一标识符，若当前小程序已绑定到微信开放平台帐号下会返回",
     * "errcode":错误码，请求失败时返回,
     * "errmsg":"错误信息，请求失败时返回"
     * }
     * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-login/code2Session.html
     */
    JSONObject wechatLogin(String jsCode);
}
